![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
@protobuf-ts/runtime-rpc
Advanced tools
Runtime library for RPC clients generated by the protoc plugin "protobuf-ts"
@protobuf-ts/runtime-rpc is a TypeScript library that provides runtime support for Protocol Buffers (protobuf) and gRPC. It allows you to create and manage gRPC clients and servers, handle streaming, and perform unary calls with ease.
Unary Calls
This feature allows you to make unary gRPC calls. The code sample demonstrates how to set up a gRPC client and make a unary call to a service method.
const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');
const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);
async function makeUnaryCall() {
const response = await client.myUnaryMethod({ myField: 'myValue' });
console.log(response);
}
makeUnaryCall();
Server Streaming
This feature allows you to handle server streaming gRPC calls. The code sample demonstrates how to set up a gRPC client and handle a server streaming method.
const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');
const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);
async function handleServerStreaming() {
const stream = client.myServerStreamingMethod({ myField: 'myValue' });
for await (const response of stream.responses) {
console.log(response);
}
}
handleServerStreaming();
Client Streaming
This feature allows you to handle client streaming gRPC calls. The code sample demonstrates how to set up a gRPC client and handle a client streaming method.
const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');
const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);
async function handleClientStreaming() {
const stream = client.myClientStreamingMethod();
stream.send({ myField: 'myValue1' });
stream.send({ myField: 'myValue2' });
stream.complete();
const response = await stream.response;
console.log(response);
}
handleClientStreaming();
Bidirectional Streaming
This feature allows you to handle bidirectional streaming gRPC calls. The code sample demonstrates how to set up a gRPC client and handle a bidirectional streaming method.
const { GrpcWebFetchTransport } = require('@protobuf-ts/runtime-rpc');
const { MyServiceClient } = require('./my-service.client');
const transport = new GrpcWebFetchTransport({ baseUrl: 'http://localhost:8080' });
const client = new MyServiceClient(transport);
async function handleBidirectionalStreaming() {
const stream = client.myBidirectionalStreamingMethod();
stream.send({ myField: 'myValue1' });
stream.send({ myField: 'myValue2' });
for await (const response of stream.responses) {
console.log(response);
}
}
handleBidirectionalStreaming();
@grpc/grpc-js is a gRPC library for Node.js that provides similar functionalities for creating and managing gRPC clients and servers. It supports unary, server streaming, client streaming, and bidirectional streaming calls. Compared to @protobuf-ts/runtime-rpc, @grpc/grpc-js is more mature and widely used in the Node.js ecosystem.
grpc-web is a JavaScript library that enables gRPC clients to communicate with gRPC servers from web browsers. It provides similar functionalities for making unary and streaming calls. Compared to @protobuf-ts/runtime-rpc, grpc-web is specifically designed for web environments and may require additional setup for server-side support.
grpc is the original gRPC library for Node.js, providing comprehensive support for gRPC clients and servers. It supports all types of gRPC calls and is widely used in production environments. Compared to @protobuf-ts/runtime-rpc, grpc is more established but may have a steeper learning curve for TypeScript developers.
Runtime library for RPC clients generated by protobuf-ts.
Install this plugin if you want to create your own RPC transport:
# with npm:
npm install @protobuf-ts/runtime-rpc
# with yarn:
yarn add @protobuf-ts/runtime-rpc
Or use one of the transports built with this package, for example Twirp via @protobuf-ts/twirp-transport or gRPC web via @protobuf-ts/grpcweb-transport.
To learn more about the types provided by this package, please read the MANUAL.
FAQs
Runtime library for RPC clients generated by the protoc plugin "protobuf-ts"
We found that @protobuf-ts/runtime-rpc demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.